package com.example.algorithm.no0206.solution;

import com.example.algorithm.no0206.ListNode;
import com.example.algorithm.no0206.Solution;

/**
 * @Description 解答实现-反转链表
 * @ClassName SolutionImpl
 * @Author Administrator
 * @Date 2020/5/16 12:48
 * @Version 1.0.0
 */
public class SolutionImpl implements Solution {
    @Override
    public ListNode reverseList(ListNode head) {
        ListNode prev = null;
        ListNode curr = head;
        while (curr != null) {
            ListNode nextTemp = curr.next;
            curr.next = prev;
            prev = curr;
            curr = nextTemp;
        }
        return prev;
    }
}
